import {
  createBrowserRouter
} from "react-router-dom";
import { loader as appLoader } from "../routes/index";
import { loader as homeLoader } from "../views/Home";
import { loader as cartLoader } from "../views/Cart";


import App from '../App'
import ErrorPage from "../error-page";
import Home from '../views/Home'
import Cate from '../views/Cate'
import Cart from '../views/Cart'
import Detail from '../views/Detail'
import My from '../views/My'
import Info from '@/views/my/Info'
import Address from '@/views/my/Address'
import Order from '@/views/my/Order'
import Login from '@/views/Login'

export const router = createBrowserRouter([
  {
    path: "/",
    element: <App />,
    errorElement: <ErrorPage />,
    loader: appLoader,
    children: [
      {
        path: '',
        element: <Home />,
        loader: homeLoader
      },
      {
        path: 'cate/:sort',
        element: <Cate />
      },
      {
        path: 'cart',
        element: <Cart />,
        loader: cartLoader
      },
      {
        path: 'detail',
        element: <Detail />
      },
      {
        path: 'my',
        element: <My />,
        children: [
          {
            path: '',
            element: <Info />
          },
          {
            path: 'address',
            element: <Address />
          },
          {
            path: 'order',
            element: <Order />
          },
        ]
      },
      {
        path: 'login',
        element: <Login />
      },
    ]
  },
]);